package io.github.kouleen.manager.listener.server;

import io.github.kouleen.minecraft.core.lang.annotation.MinecraftPluginListener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerListPingEvent;

/**
 * 客户端向服务器发送 ping 请求以获取服务器列表信息时被触发。
 * @author zhangqing
 * @since 2025/2/26 11:07
 */
@MinecraftPluginListener
public class ServerListPingListener implements Listener {

    @EventHandler
    public void onServerListPingListener(ServerListPingEvent serverListPingEvent){
        // 获取服务器名称
        String serverListMotd = serverListPingEvent.getMotd();
        System.out.println(serverListMotd);
        serverListPingEvent.setMotd("空岛生存");
        // 获取最大玩家数量
        int maxPlayers = serverListPingEvent.getMaxPlayers();
        System.out.println(maxPlayers);
        // 获取玩家数量
        int numPlayers = serverListPingEvent.getNumPlayers();
        System.out.println(numPlayers);
    }
}
